﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：IDapperImplementor.cs
// 功能描述：TongTongMall.Dapper
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using TongTongMall.Dapper.DapperExtensions.Sql;
using TongTongMall.Dependecy;
using TongTongMall.Domain.PredicateForDapper;

namespace TongTongMall.Dapper.DapperExtensions
{
    /// <summary>
    /// dapper实现层
    /// </summary>
    public interface IDapperImplementor : ISingletonDependency
    {
        ISqlGenerator SqlGenerator { get; }

        dynamic Insert<T>(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class,new();

        Task<dynamic> InsertAsync<T>(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class,new();
        bool Update<T>(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class, new();

        Task<bool> UpdateAsync<T>(IDbConnection connection, T entity, IDbTransaction transaction, int? commandTimeout) where T : class, new();
        bool Update<T>(IDbConnection connection, object entity, object whereClip, IDbTransaction transaction, int? commandTimeout) where T : class,new();

        Task<bool> UpdateAsync<T>(IDbConnection connection, object entity, object whereClip, IDbTransaction transaction, int? commandTimeout) where T : class,new();

        bool Delete<T>(IDbConnection connection, object predicate, IDbTransaction transaction, int? commandTimeout) where T : class,new();

        Task<bool> DeleteAsync<T>(IDbConnection connection, object predicate, IDbTransaction transaction, int? commandTimeout) where T : class,new();

        IEnumerable<T> GetList<T>(IDbConnection connection, object predicate, IList<ISort> sort, IDbTransaction transaction, Expression<Func<T, object>> selector, int? commandTimeout, bool buffered) where T : class,new();

        Task<IEnumerable<T>> GetListAsync<T>(IDbConnection connection, object predicate, IList<ISort> sort, IDbTransaction transaction, Expression<Func<T, object>> selector, int? commandTimeout, bool buffered) where T : class,new();

        int Count<T>(IDbConnection connection, object predicate, IDbTransaction transaction, int? commandTimeout) where T : class,new();

        Task<int> CountAsync<T>(IDbConnection connection, object predicate, IDbTransaction transaction, int? commandTimeout) where T : class,new();



        IEnumerable<T> QueryPaged<T>(IDbConnection connection, int pageIndex, int pageSize, object predicate, IList<ISort> sort, Expression<Func<T, object>> selector, IDbTransaction transaction, int? commandTimeout, bool buffered) where T : class, new();


        Task<IEnumerable<T>> QueryPagedAsync<T>(IDbConnection connection, int pageIndex, int pageSize, object predicate, IList<ISort> sort, Expression<Func<T, object>> selector, IDbTransaction transaction, int? commandTimeout) where T : class, new();


        void TriggerDomainEvents(object aggreateRoot);
    }
}
